// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asAnimatedMeshComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the AnimatedMeshComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asAnimatedMeshComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"
#include "asSceneComponent.h"

#include "../../../components/scene/AnimatedMeshComponent.h"


//! Reference factory for the AnimatedMeshComponent class.
AnimatedMeshComponent* createAnimatedMeshComponent(Entity *parent)
{
    return new AnimatedMeshComponent(parent);
}

//! Reference factory for the AnimatedMeshComponent class.
AnimatedMeshComponent* createAnimatedMeshComponent(Entity *parent, const std::string &fileName,
                                                         const vector3df &scale)
{
    return new AnimatedMeshComponent(parent, fileName, scale);
}

//! Binds the AnimatedMeshComponent class to AngelScript.
void bindAnimatedMeshComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind AnimatedMeshComponent class.
    r = engine->RegisterObjectType("AnimatedMeshComponent", sizeof(AnimatedMeshComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindSceneComponentBase<AnimatedMeshComponent>(engine, "AnimatedMeshComponent");

    // Set SkyDomeComponent behaviour.
    r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_FACTORY, "AnimatedMeshComponent@ f(Entity @+)",
                                        asFUNCTIONPR(createAnimatedMeshComponent, (Entity*), AnimatedMeshComponent*),
                                        asCALL_CDECL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_FACTORY, "AnimatedMeshComponent@ f(Entity @+, " \
                                        "const string &in, const vector3df &in)", asFUNCTIONPR(createAnimatedMeshComponent,
                                        (Entity*, const std::string&, const vector3df&), AnimatedMeshComponent*),
                                        asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "AnimatedMeshComponent& opAssign(const AnimatedMeshComponent &in)",
                                     asFUNCTION(assignT<AnimatedMeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);

    // Bind AnimatedMeshComponent class functions.
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void animate()",
                                     asMETHOD(AnimatedMeshComponent, animate), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "s32 getEndFrame()",
                                     asMETHOD(AnimatedMeshComponent, getEndFrame), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "f32 getFrame()",
                                     asMETHOD(AnimatedMeshComponent, getFrame), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "s32 getStartFrame()",
                                     asMETHOD(AnimatedMeshComponent, getStartFrame), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setAnimationSpeed(f32)",
                                     asMETHOD(AnimatedMeshComponent, setAnimationSpeed), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setCurrentFrame(f32)",
                                     asMETHOD(AnimatedMeshComponent, setCurrentFrame), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setFrameLoop(s32, s32)",
                                     asMETHOD(AnimatedMeshComponent, setFrameLoop), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setLoopMode(bool)",
                                     asMETHOD(AnimatedMeshComponent, setLoopMode), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setMD2Animation(const string &in)",
                                     asMETHODPR(AnimatedMeshComponent, setMD2Animation, (const std::string&), void),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setMesh(const string &in)",
                                     asMETHODPR(AnimatedMeshComponent, setMesh, (const std::string&), void),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setShadowVolumeMesh(const string &in)",
                                     asMETHODPR(AnimatedMeshComponent, setShadowVolumeMesh, (const std::string&), void),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setShadowVolumeSceneNode(const string &in, " \
                                     "bool, f32)", asMETHODPR(AnimatedMeshComponent, setShadowVolumeSceneNode,
                                     (const std::string&, bool, f32), void), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setTransitionTime(f32)",
                                     asMETHOD(AnimatedMeshComponent, setTransitionTime), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
